<!--头部公共部分-->
{include file="common/header" /}

<div style="padding:15px;font-size: 14px;">
    <form class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="font-size: 12px;">订单编号</label>
                <div class="layui-input-inline">
                    <input type="text" name="contract_number" readonly value='{$receipt_number.contract_number}'
                           autocomplete="off"   class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="font-size: 12px;">收款凭证号</label>
                <div class="layui-input-inline">
                    <input type="text" name="receipt_number" readonly value='{$receipt_number.receipt_number}'
                           autocomplete="off"   class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="font-size: 12px;">退款凭证号</label>
                <div class="layui-input-inline">
                    <input type="text" name="refund_voucher" readonly value='{$receipt_number.refund_voucher}'
                           autocomplete="off"   class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" name="amount" style="font-size: 12px;">退款金额(元)</label>
                <div class="layui-input-inline">
                    <input type="text" readonly name="amount" value='{$receipt_number.amount}' autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <button class="layui-btn layui-btn-sm layui-btn-primary"  style="width:80px;" id="cancle"  readonly>取消</button>
            <input class="layui-btn layui-btn-sm layui-btn-normal" lay-submit lay-filter="form" style="width:80px;" value="保存" readonly>
        </div>
    </form>
</div>
<!--底部公共部分-->
{include file="common/footer" /}
<script>
    layui.use(['element', 'jquery', 'form', 'laydate', 'layer'], function () {
        let $ = layui.$,
            layer = layui.layer,
            form = layui.form;
        //监听提交
        form.on('submit(form)', function (data) {
            let field = data.field;
            layer.confirm('将对订单{$receipt_number.contract_number}发起退款，确定要继续操作吗？', {icon: 3, title:'退款确认'}, function(index) {
            $.ajax({
                url: '{:url("Finance/refund")}',
                method: "post",
                data: field,
                beforeSend: function () {
                    let index = layer.load(1, {
                        shade: [0.1,'#fff'] //0.1透明度的白色背景
                    });
                },
                success: function (result) {
                    layer.msg(result.msg);
                    setTimeout(function () {
                        let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        parent.location.reload();
                    }, 1000);
                },
                complete: function () {
                },
                error: function (error) {
                    console.log(error)
                }
            });
            return false;
            });
        });
        //取消
        $('#cancle').click(function () {
            let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
            return false;
        });
    });
</script>
